<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/review.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons">
	  <a onclick="location = '<?php echo $insert; ?>'" class="button"><?php echo $button_insert; ?></a>
	  <a onclick="$('form').submit();" class="button"><?php echo $button_delete; ?></a>
	  <a onclick="$('form').attr('action','<?php echo $publish; ?>').submit();" class="button"><?php echo $button_publish; ?></a>
	  <a onclick="$('form').attr('action','<?php echo $unpublish; ?>').submit();" class="button"><?php echo $button_unpublish; ?></a>
	  
	  </div>
	   </div>
    <div class="content">
      <form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
            <tr>
              <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
              <td class="left"><?php if ($sort == 'bpd.title') { ?>
                <a href="<?php echo $sort_product; ?>" class="<?php echo strtolower($order); ?>">Post Title</a>
                <?php } else { ?>
                <a href="<?php echo $sort_product; ?>">Post Title</a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'bc.author') { ?>
                <a href="<?php echo $sort_author; ?>" class="<?php echo strtolower($order); ?>">Author</a>
                <?php } else { ?>
                <a href="<?php echo $sort_author; ?>">Author</a>
                <?php } ?></td>
              <td style="text-align:center;"><?php if ($sort == 'bc.rating') { ?>
                <a href="<?php echo $sort_rating; ?>" class="<?php echo strtolower($order); ?>">Rating</a>
                <?php } else { ?>
                <a href="<?php echo $sort_rating; ?>">Rating</a>
                <?php } ?></td>
              <td  style="text-align: center;"><?php if ($sort == 'bc.status') { ?>
                <a href="<?php echo $sort_status; ?>" class="<?php echo strtolower($order); ?>">Approved</a>
                <?php } else { ?>
                <a href="<?php echo $sort_status; ?>">Approved</a>
                <?php } ?></td>
			 <td  style="text-align: center;"><?php if ($sort == 'bc.published') { ?>
                <a href="<?php echo $sort_status; ?>" class="<?php echo strtolower($order); ?>">Status</a>
                <?php } else { ?>
                <a href="<?php echo $sort_status; ?>">Status</a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'bc.created') { ?>
                <a href="<?php echo $sort_date_added; ?>" class="<?php echo strtolower($order); ?>">Date Added</a>
                <?php } else { ?>
                <a href="<?php echo $sort_date_added; ?>">Date Added</a>
                <?php } ?></td>
              <td class="right">Action</td>
            </tr>
          </thead>
          <tbody>
		  <tr class="filter">
              <td></td>
              <td><input type="text" name="filter_title" value="<?php echo $filter_title; ?>" /></td>
			  <td><input type="text" name="filter_author_name" value="<?php echo $filter_author_name; ?>" /></td>
			  <td style="text-align:center;"><input type="text" name="filter_rating" value="<?php echo $filter_rating; ?>" /></td>
			  
              <td style="text-align: center;"><select name="filter_approved">
                  <option value="*"></option>
                  <?php if ($filter_approved) { ?>
                  <option value="1" selected="selected">Approved</option>
                  <?php } else { ?>
                  <option value="1">Approved</option>
                  <?php } ?>
                  <?php if (!is_null($filter_approved) && !$filter_approved) { ?>
                  <option value="0" selected="selected">Not Approved</option>
                  <?php } else { ?>
                  <option value="0">Not Approved</option>
                  <?php } ?>
                </select></td>
			  
			   <td style="text-align: center;"><select name="filter_published">
                  <option value="*"></option>
                  <?php if ($filter_published) { ?>
                  <option value="1" selected="selected">Published</option>
                  <?php } else { ?>
                  <option value="1">Published</option>
                  <?php } ?>
                  <?php if (!is_null($filter_published) && !$filter_published) { ?>
                  <option value="0" selected="selected">UnPublished</option>
                  <?php } else { ?>
                  <option value="0">UnPublished</option>
                  <?php } ?>
                </select></td>
			   <td></td>
              <td align="right"><a onclick="filter(); return false;" class="button">Filter</a></td>
            </tr>
            <?php if ($comments) { ?>
			<?php foreach ($comments as $comment) { ?>
            <tr>
              <td style="text-align: center;"><?php if ($comment['selected']) { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $comment['id']; ?>" checked="checked" />
                <?php } else { ?>
                <input type="checkbox" name="selected[]" value="<?php echo $comment['id']; ?>" />
                <?php } ?></td>
              <td class="left"><a href="<?php echo $edit_post_link;?>&id=<?php echo $comment['blog_post_id']; ?>"><?php echo $comment['title']; ?></a></td>
              <td class="left"><?php echo $comment['author_name']; ?> <br /><i><a href="mailto:<?php echo $comment['author_email'];?>"><?php echo $comment['author_email'];?></a></i></td>
              <td style="text-align:center;"><?php echo $comment['rating']; ?></td>
              <td  style="text-align: center;"><?php echo $comment['approved']; ?></td>
			   <td  style="text-align: center;"><?php echo $comment['published']; ?></td>
              <td class="left"><?php echo $comment['created']; ?></td>
              <td class="right"><?php foreach ($comment['action'] as $action) { ?>
                [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                <?php } ?></td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="8"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function filter() {
	url = 'index.php?route=blog/comment&token=<?php echo $token; ?>';
	
	var filter_title = $('input[name=\'filter_title\']').attr('value');
	
	if (filter_title) {
		url += '&filter_title=' + encodeURIComponent(filter_title);
	}
	
	var filter_author_name = $('input[name=\'filter_author_name\']').attr('value');
	
	if (filter_author_name) {
		url += '&filter_author_name=' + encodeURIComponent(filter_author_name);
	}
	
	var filter_rating = $('input[name=\'filter_rating\']').attr('value');
	
	if (filter_rating) {
		url += '&filter_rating=' + encodeURIComponent(filter_rating);
	}
	
	
	var filter_approved = $('select[name=\'filter_approved\']').attr('value');

	if (filter_approved != '*') {
		url += '&filter_approved=' + encodeURIComponent(filter_approved);
	}	
	
	var filter_published = $('select[name=\'filter_published\']').attr('value');

	if (filter_published != '*') {
		url += '&filter_published=' + encodeURIComponent(filter_published);
	}	
	

	$('form').attr('action', url).submit();
}
//--></script> 
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
//--></script> 
<?php echo $footer; ?>